<?php


$header .= '
	<script language="javascript" type="text/javascript">
	function logoutFunction(){
		var ajaxRequest;  // The variable that makes Ajax possible!
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				window.location = "'.$addr.this_page().'";
			}
		}
		ajaxRequest.open("GET", "'.$addr.'/handle/logout_ajax.php", true);
		ajaxRequest.send(null);
		
	}
	
	function homeFunction() {
		window.location = "'.$addr.'";
	}
	</script>
';

$header .= '
	<div onclick="homeFunction()" id="title">'.$GLOBALS['SITE_NAME'].'</div>
';

/*
**	L O G I N
**	    T O O L B O X
*/
		$header .='
			<div class="roundedcornr_box_toolbox">
   			<div class="roundedcornr_top_toolbox"><div></div></div>
   		';
	// If logged in
	if(isset($m_username)){
		$header .= '
			<div class="toolbox">
			<P>Welcome '.$m_name.'!</P>
			<ul>
			<li><img src="'.$addr.'/imgs/home.gif" /> <a href="'.$addr.'/profile.php?id='.$m_user_id.'">My Profile</a></li>
			<li><img src="'.$addr.'/imgs/message.gif" /> <a href="'.$addr.'/messages.php">Inbox</a></li>
			<li><img src="'.$addr.'/imgs/key.png" /> <a onclick="logoutFunction()" style="cursor:pointer">Logout</a></li>
			</ul>
			</div>
		';
	
	// If not logged in
	}else if(!isset($m_username)){
		$header .= '
			<div class="toolbox">
			<ul>
			<li><img src="'.$addr.'/imgs/member-profile.png" /> <a href="'.$addr.'/register.php">Create an Account</a></li>
			<li><img src="'.$addr.'/imgs/key.png" /> <a href="'.$addr.'/login.php">Login</a></li>
			</ul>
			</div>
		';
	}
		$header .='
			<div class="roundedcornr_bottom_toolbox"><div></div></div>
			</div>
		';

/*
**	M A I N    L I N K B O X
*/
	$header .= '
		<div class="linksbox">
			<div class="box"><P><a href="'.$addr.'/howitworks.php">How It Works</a></P></div>
			<div class="box"><P><a href="'.$addr.'/search.php">Search</a></P></div>
			<div class="box"><P><a href="'.$addr.'/donate.php">Donate</a></P></div>
			<div class="box"><P><a href="'.$addr.'/aboutus.php">About Us</a></P></div>
		</div>
	';

?>